// invoke的封装
export const invoke = function (url, params = {}, type = 'data') {
  return new Promise((resolve, reject) => {
    window.electronAPI.invoke(url, params).then(v => {
      if(!v) { return resolve(v)}
      const {code, data, msg = ''} = v
      if(code != 0 && code != 200) {
        reject(msg)
        return _.message.error(msg) 
      }
      resolve(type == 'data' ? data : v)
    })
  })
}